package com.mz.ozy.mvp.presenter;


import android.app.Activity;
import android.content.Context;

import com.mz.ozy.base.BasePresenterImpl;
import com.mz.ozy.bean.C2cTradeBean;
import com.mz.ozy.mvp.model.C2cTradeModel;
import com.mz.ozy.mvp.view.C2cTradeContract;
import com.mz.ozy.net.MyObserver;
import com.mz.ozy.utils.RxUtil;

import okhttp3.ResponseBody;

/**
 * Created by administrator on 2018/12/3.
 */
public class C2cTradePresenter extends BasePresenterImpl<C2cTradeContract.View> implements C2cTradeContract.Presenter {

    private C2cTradeModel mModel;

    public C2cTradePresenter() {
        mModel = new C2cTradeModel();
    }


    @Override
    public void geAssetsInfo(Activity activity, String type, String page, boolean load) {
        mModel.geAssetsInfo(activity, type, page)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<C2cTradeBean>(mView, load) {
                    @Override
                    public void onSuccesss(C2cTradeBean bean) {
                        mView.geAssetsInfoSuccess(bean);
                    }
                });
    }

    @Override
    public void submitOrder(Context context, String id, String type, String number, String password) {
        mModel.submitOrder(context, id, type, number, password)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<C2cTradeBean>(mView) {
                    @Override
                    public void onSuccesss(C2cTradeBean bean) {
                        mView.submitOrderSuccess(bean);
                    }
                });
    }
}
